﻿using System;
using System.Linq;
using System.Windows.Media;

namespace CSharp.Libs.WPF.UserControls
{
    public class MapViewKoordItem
    {
        #region declarations
        private Int32 _intX = 0;
        private Int32 _intY = 0;
        private String _strPlayerName = "";
        private String _strPlayerMight = "";
        private String _strAlliance = "";
        private String _strCityName = "";
        private String _strOnlineStatus = "";
        private String _strLastLogin = "";
        private SolidColorBrush _scbColor = Brushes.Red;
        #endregion



        #region constructor / terminator
        public MapViewKoordItem(
            Int32 X, 
            Int32 Y)
        {
            _intX = X;
            _intY = Y;
        }

        public MapViewKoordItem(
            String KoordString)
        {
            _SetCoords(KoordString);
        }

        public MapViewKoordItem(
            String KoordString,
            String PlayerName,
            String PlayerMight,
            String Alliance,
            String CityName,
            String OnlineStatus,
            String LastLogin)
        {
            _SetCoords(KoordString);
            _SetPlayerStats(PlayerName, PlayerMight, Alliance, CityName, OnlineStatus, LastLogin);
        }

        public MapViewKoordItem(
            String KoordString,
            String PlayerName,
            String PlayerMight,
            String Alliance,
            String CityName,
            String OnlineStatus,
            String LastLogin,
            SolidColorBrush Color)
        {
            _SetCoords(KoordString);
            _SetPlayerStats(PlayerName, PlayerMight, Alliance, CityName, OnlineStatus, LastLogin);
            _SetColor(Color);
        }
        #endregion



        #region private functions
        private void _SetCoords(
            String KoordString)
        {
            if (KoordString.Contains(","))
            {
                String[] strSplit = KoordString.Split(',');
                if (strSplit.Count() == 2)
                {
                    Int32.TryParse(strSplit[0], out _intX);
                    Int32.TryParse(strSplit[1], out _intY);
                }
            }
        }

        private void _SetPlayerStats(
            String PlayerName,
            String PlayerMight,
            String Alliance,
            String CityName,
            String OnlineStatus,
            String LastLogin)
        {
            _strPlayerName = PlayerName;
            _strPlayerMight = PlayerMight;
            _strAlliance = Alliance;
            _strCityName = CityName;
            _strOnlineStatus = OnlineStatus;
            _strLastLogin = LastLogin;
        }

        private void _SetColor(
            SolidColorBrush Color)
        {
            _scbColor = Color;
        }
        #endregion



        #region interface
        #region properties
        public Int32 X
        {
            get
            {
                return _intX;
            }
            set
            {
                _intX = value;
            }
        }

        public Int32 Y
        {
            get
            {
                return _intY;
            }
            set
            {
                _intY = value;
            }
        }

        public String CityName
        {
            get
            {
                return _strCityName;
            }
            set
            {
                _strCityName = value;
            }
        }

        public String Alliance
        {
            get
            {
                return _strAlliance;
            }
            set
            {
                _strAlliance = value;
            }
        }

        public String PlayerName
        {
            get
            {
                return _strPlayerName;
            }
            set
            {
                _strPlayerName = value;
            }
        }

        public String PlayerMight
        {
            get
            {
                return _strPlayerMight;
            }
            set
            {
                _strPlayerMight = value;
            }
        }

        public String LastLogin
        {
            get
            {
                return _strLastLogin;
            }
            set
            {
                _strLastLogin = value;
            }
        }

        public String OnlineStatus
        {
            get
            {
                return _strOnlineStatus;
            }
            set
            {
                _strOnlineStatus = value;
            }
        }

        public SolidColorBrush Color
        {
            get
            {
                return _scbColor;
            }
            set
            {
                _scbColor = value;
            }
        }
        #endregion

        #region methods
        #endregion
        #endregion
    }
}
